package com.ww.basic.implicits

object Test5 {
  case class StrategyConfig(
                             feeRate: Double,
                             slipPoint: Double,
                             maxPosition: Int
                           )

  def calculateProfit(
                       buyPrice: Double,
                       sellPrice: Double,
                       quantity: Int
                     )(implicit config: StrategyConfig): Double = {
    val profit = (sellPrice - buyPrice) * quantity
    val cost = profit * config.feeRate + quantity * buyPrice * config.slipPoint
    profit - cost
  }

  implicit val defaultConfig: StrategyConfig = StrategyConfig(
    feeRate = 0.0005, slipPoint = 0.001, maxPosition = 1000
  )

  def main(args: Array[String]): Unit = {
    val netProfit = calculateProfit(buyPrice = 3.14, sellPrice = 35.0, quantity = 400)
    println(netProfit)
  }
}